Reduce XCTest permission watchdog CPU usage and make its polling interval tunable#163
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
V3RON
force-pushed
the
perf/xctest-permission-watchdog-polling
branch
from
July 15, 2026 07:32
0af8935 to
4ff6f26
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this?
This PR sharply reduces the CPU cost of the iOS permission-dialog watchdog that runs inside the XCTest agent when
permissionsis enabled. Previously, every watchdog tick evaluated 11 known button labels against SpringBoard, and each evaluation triggered a separate cross-process accessibility snapshot — roughly one snapshot every 100 ms, continuously, for the whole session. On busy CI runners (notablymacos-26-arm64) this kept the agent,testmanagerd, and SpringBoard permanently busy and degraded overall test performance. It also makes the watchdog's polling interval tunable without rebuilding the agent.How does it work?
The watchdog's idle path now costs a single accessibility snapshot per tick: one query matches SpringBoard buttons against the full set of known permission-button labels with a
label IN {…}predicate. Only when that guard matches — meaning a permission dialog is actually on screen — does the watchdog fall back to the existing priority-ordered label loop, so tap selection on multi-button dialogs (for example preferring "While Using the App" over "Allow Once") behaves exactly as before.The tick interval keeps its 1-second default so permission dialogs are still accepted quickly enough for tight test timeouts, but it can now be overridden through the
HARNESS_XCTEST_AGENT_TICK_INTERVAL_MSenvironment variable: the harness forwards it from its own environment into the agent's launch environment, and the agent falls back to the default when the value is unset or invalid. Combined with the single-snapshot guard, idle snapshot volume drops from ~11 per second to ~1 per second.Why is this useful?
permissionsenabled no longer pay a constant CPU tax for the whole session, which directly improves test performance and stability on CI runners.The branch also carries the playground
testTimeoutraise to 10 s (cherry-picked), since slow CI UI interactions onmacos-26-arm64runners were already hitting the previous 5 s budget independently of the watchdog.